package com.hcf.admin.config;

import com.hcf.admin.common.biz.user.UserContextInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new UserContextInterceptor(stringRedisTemplate))
                .addPathPatterns("/**") //应用于所有请求
        .excludePathPatterns("/**/login", "/**/has-username/**","/**/title", "/**/is-login"); // 排除登录和注册路径
    }
}
